//
//  BlockViewController.m
//  MRC_Playground
//
//  Created by Developer on 2021/9/30.
//

#import "BlockViewController.h"
#import "BlockView.h"

@interface BlockViewController ()
@property(nonatomic, retain)UILabel *titleLabel;
@end

@implementation BlockViewController{
    BlockView *_redView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    self.titleLabel.text = @"title";
    [self.view addSubview:self.titleLabel];
    
    __block typeof(self) weakSelf = self;
    _redView = [[BlockView alloc] initWithFrame:CGRectMake(100, 200, 100, 100)];
    _redView.backgroundColor = [UIColor redColor];
    _redView.dismissCallback = ^{
        //如果不使用weakSelf则无法进入dealloc
        weakSelf.titleLabel.text = @"changed";
    };
    [self.view addSubview:_redView];
}

- (void)dealloc{
    [_redView release]; _redView = nil;
    [_titleLabel release]; _titleLabel = nil;
    [super dealloc];
}


@end
